package com.hiultra.archive.controller;


import javax.servlet.http.HttpServletResponse;

import com.hiultra.archive.domain.ArcAccountType;
import com.hiultra.archive.domain.ArcArchive;
import com.hiultra.archive.service.IArcAccountTypeService;
import com.hiultra.common.utils.poi.ExcelUtil;
import io.swagger.annotations.ApiOperation;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.hiultra.common.annotation.Log;
import com.hiultra.common.core.controller.BaseController;
import com.hiultra.common.core.domain.AjaxResult;
import com.hiultra.common.enums.BusinessType;
import com.hiultra.common.core.page.TableDataInfo;
import org.springframework.web.multipart.MultipartFile;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;

/**
 * 类型编号Controller
 * 
 * @author ruoyi
 * @date 2024-07-16
 */
@RestController
@RequestMapping("/base/type")
public class ArcAccountTypeController extends BaseController
{
    @Autowired
    private IArcAccountTypeService arcAccountTypeService;

    /**
     * 查询类型编号列表
     */
    @PreAuthorize("@ss.hasPermi('base:type:list')")
    @GetMapping("/list")
    public TableDataInfo list(ArcAccountType arcAccountType)
    {
        startPage();
        List<ArcAccountType> list = arcAccountTypeService.selectArcAccountTypeList(arcAccountType);
        return getDataTable(list);
    }


    /**
     * 导出类型编号列表
     */
    @PreAuthorize("@ss.hasPermi('base:type:export')")
    @Log(title = "类型编号", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ArcAccountType arcAccountType)
    {
        List<ArcAccountType> list = arcAccountTypeService.selectArcAccountTypeList(arcAccountType);
        ExcelUtil<ArcAccountType> util = new ExcelUtil<ArcAccountType>(ArcAccountType.class);
        util.exportExcel(response, list, "类型编号数据");
    }

    /**
     * 获取类型编号详细信息
     */
    @PreAuthorize("@ss.hasPermi('base:type:query')")
    @GetMapping(value = "/{typeCode}")
    public AjaxResult getInfo(@PathVariable("typeCode") Long typeCode)
    {
        return AjaxResult.success(arcAccountTypeService.selectArcAccountTypeByTypeCode(typeCode));
    }

    /**
     * 新增类型编号
     */
    @PreAuthorize("@ss.hasPermi('base:type:add')")
    @Log(title = "类型编号", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ArcAccountType arcAccountType)
    {
        arcAccountType.setCreateBy(getUsername());
        return toAjax(arcAccountTypeService.insertArcAccountType(arcAccountType));
    }

    /**
     * 修改类型编号
     */
    @PreAuthorize("@ss.hasPermi('base:type:edit')")
    @Log(title = "类型编号", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ArcAccountType arcAccountType)
    {
        arcAccountType.setUpdateBy(getUsername());
        return toAjax(arcAccountTypeService.updateArcAccountType(arcAccountType));
    }

    /**
     * 删除类型编号
     */
    @PreAuthorize("@ss.hasPermi('base:type:remove')")
    @Log(title = "类型编号", businessType = BusinessType.DELETE)
	@DeleteMapping("/{typeCodes}")
    public AjaxResult remove(@PathVariable Long[] typeCodes)
    {
        return toAjax(arcAccountTypeService.deleteArcAccountTypeByTypeCodes(typeCodes));
    }
}
